const { build, context } = require("esbuild");
const { resolve } = require("path");
const pkg = require(`./package.json`);
const fg = require("fast-glob");

const files = fg.sync("src/*/index.ts");

const entryList = files.map((file) => {
    return {
        in: file,
        out: file.replace(/(src)|(\.ts)/gi, ""),
    };
});

// console.log("[ entryList ]-9", entryList);

build({
    entryPoints: entryList,
    outdir: resolve(__dirname, "./dist"),
    bundle: true,
    sourcemap: false,
    format: "esm",
    globalName: pkg.buildOptions?.name,
    platform: "browser",
    minify: true,
}).then((r) => console.log("构建完成"));
